package com.qf.rabbitmq.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    private RabbitTemplate rabbitTemplate;

    @Autowired
    public void setRabbitTemplate(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @GetMapping("/queue")
    public String test2Queue(){
        rabbitTemplate.convertAndSend("rspringboot","这是来自于 2022 年的消息");
        return "success";
    }

    @GetMapping("/fanout")
    public String test2fanout(){
        rabbitTemplate.convertAndSend("dfgshjk","","人生短短几个秋,不醉不罢休");
        return "success";
    }

    @GetMapping("/fanout1")
    public String test2fanout1(){
        rabbitTemplate.convertAndSend("dfgshjkasdasda","","人生短短几个秋,不醉不罢休");
        return "success";
    }
}
